#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>


//专注！！！！！1
using namespace std;
using LL = long long;
const int N = 55;

int n, m;
char str[N];
int g[N][N];
bool st[N][N];

int dis[4][2][2] = {
    {{-1, 0}, {0, 1}}, 
    {{1, 0}, {0, 1}}, 
    {{1, 0}, {0, -1}}, 
    {{-1, 0}, {0, -1}}
};

int wa[4][12][2] = {
    {{-2, -1}, {-2, 0}, {-2, 1}, {-1, -1}, {-1, 1}, {-1, 2}, {0, -1}, {0, 2}, {1, -1}, {1, 0}, {1, 1}, {1, 2}},
    {{-1, -1}, {-1, 0}, {-1, 1}, {-1, 2}, {0, -1}, {0, 2}, {1, -1}, {1, 1}, {1, 2}, {2, -1}, {2, 0}, {2, 1}},
    {{-1, -2}, {-1, -1}, {-1, 0}, {-1, 1}, {0, -2}, {0, 1}, {1, -2}, {1, -1}, {1, 1}, {2, -1}, {2, 0}, {2, 1}},
    {{-2, -1}, {-2, 0}, {-2, 1}, {-1, -2}, {-1, -1}, {-1, 1}, {0, -2}, {0, 1}, {1, -2}, {1, -1}, {1, 0}, {1, 1}}
};

bool check_in(int x, int y){
    if(x >= 1 && x <= n && y >= 1 && y <= m){
        return true;
    }else{
        return false;
    }
}


int check_L(int x, int y){
    for(int i = 0; i < 4; i ++){
        int nx1 = x + dis[i][0][0], ny1 = y + dis[i][0][1];
        int nx2 = x + dis[i][1][0], ny2 = y + dis[i][1][1];

        if(!check_in(nx1, ny1) || !check_in(nx2, ny2)) continue;

        if(g[nx1][ny1] && g[nx2][ny2]){
            st[x][y] = true;
            st[nx1][ny1] = true;
            st[nx2][ny2] = true;
            return i;
        }
    }
    return -1;
}


bool check_have(int x, int y, int type){
    for(int i = 0; i < 12; i ++){
        int nx = x + wa[type][i][0], ny = y + wa[type][i][1];
        
        if(!check_in(nx, ny)) continue;
        if(g[nx][ny]){
            return false;
        }
    }

    return true;
}

bool check_all(){
    for(int i = 1; i <= n; i ++){
        for(int j = 1; j <= m; j ++){
            if(g[i][j] && !st[i][j]){
                return false;
            }
        }
    }

    return true;
}


void solve(){
    memset(st, 0, sizeof st);

    
    for(int i = 1; i <= n; i ++){
        scanf("%s", str + 1);
        for(int j = 1; j <= m; j ++){
            if(str[j] == '.'){
                g[i][j] = 0;
            }else{
                g[i][j] = 1;
            }
        }
    }


    for(int i = 1; i <= n; i ++){
        for(int j = 1; j <= m; j ++){
            if(g[i][j] && !st[i][j]){
                int t = check_L(i, j);
                if(t != -1){
                    if(!check_have(i, j, t)){
      
                        printf("NO\n");
                        return;
                    }
                }
            }
        }
    }


    if(check_all()){
        printf("YES\n");
    }else{
        printf("NO\n");
    }




}


int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    int T;
    scanf("%d", &T);
    for(int i = 1; i <= T; i ++){
        scanf("%d%d", &n, &m);

        solve();
    }
    
    return 0;


}
   